<?php
/**
 * Created by PhpStorm.
 * @author zhuyujun
 * Date: 2017/10/24
 * Time: 16:25
 */
namespace App\Eloquent\Ygt;

use Framework\BaseClass\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class AssemblageMaterial extends DbEloquent
{
    use SoftDeletes;
    protected $dates = ['deleted_at'];
    protected $table = 'ygt_assemblage_material';

    public function fields(){
        return $this->hasMany('App\Eloquent\Ygt\ProductFields');
    }

    //取列表
    //适用于
    //库存管理
    //集合材料
    public static function getListByJoinAssemblageMaterial($where,$limit=10,$offset=0,$orderby=['ygt_assemblage_material.id','desc'])
    {
        $join = [
            ['table'=>'ygt_img_upload','field_l'=>'ygt_assemblage_material.img_id','field_c'=>'=','field_r'=>'ygt_img_upload.id'],
        ];
        $column             = 'ygt_assemblage_material.id,ygt_assemblage_material.product_name,ygt_assemblage_material.product_no';
        $column             .= ',ygt_assemblage_material.is_public,ygt_assemblage_material.barcode,ygt_assemblage_material.number';
        $column             .= ',ygt_assemblage_material.warning_number,ygt_assemblage_material.full_number';
        $column             .= ',ygt_assemblage_material.category_id,ygt_assemblage_material.price,ygt_assemblage_material.unit';
        $column             .= ',ygt_assemblage_material.created_at,ygt_assemblage_material.img_id';
        $column             .= ',ygt_img_upload.img_url';
        $groupby            = '';
        $result             = self::getList($where,$column,$limit,$offset,$orderby,$groupby,$join);
        return $result;
    }

}